import os
import json
import logging

# （1）日志信息
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s'
)

# （2）确定CET4单词数据的路径
word_data_path = 'data/all/global-words-sample.json'
word_analysis_dir = 'result/all'
article_dir = 'result/articles'
search_json_path = "web/search.json"


def main():
    with open(word_data_path,'r',encoding='utf-8') as f:
        words_data = json.load(f) # 转字典，文件对象f中读取JSON数据，并将其转换为Python字典或列表等数据结构
        print(words_data)
    words_data_map = {}
    for word in words_data['words']:
        # print(f"word:{word}")
        first_letter = word["word"][0]
        word_ana_file = f"{word['word']}.json" if first_letter.islower() else f"{word['word']}2.json"
        word_ana_path = os.path.join(word_analysis_dir, first_letter.lower(), word_ana_file)
        # print(f"first_letter:{first_letter}") # n

#         word:{'word': 'nauseous', 'translations': [{'translation': ' 恶心的； 令人作呕的， 令人厌恶的', 'type': 'adj'}], 'seq': 12654}


if __name__ == '__main__':
    main()

